package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WcsPolicySort;
import com.ruoyi.system.service.IWcsPolicySortService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平均分配参数Controller
 * 
 * @author ZYT
 * @date 2020-08-28
 */
@RestController
@RequestMapping("/system/WcsPolicySort")
public class WcsPolicySortController extends BaseController
{
    @Autowired
    private IWcsPolicySortService wcsPolicySortService;

    /**
     * 查询平均分配参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:WcsPolicySort:list')")
    @GetMapping("/list")
    public TableDataInfo list(WcsPolicySort wcsPolicySort)
    {
        startPage();
        List<WcsPolicySort> list = wcsPolicySortService.selectWcsPolicySortList(wcsPolicySort);
        return getDataTable(list);
    }

    /**
     * 导出平均分配参数列表
     */
    @PreAuthorize("@ss.hasPermi('system:WcsPolicySort:export')")
    @Log(title = "平均分配参数", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WcsPolicySort wcsPolicySort)
    {
        List<WcsPolicySort> list = wcsPolicySortService.selectWcsPolicySortList(wcsPolicySort);
        ExcelUtil<WcsPolicySort> util = new ExcelUtil<WcsPolicySort>(WcsPolicySort.class);
        return util.exportExcel(list, "WcsPolicySort");
    }

    /**
     * 获取平均分配参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:WcsPolicySort:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wcsPolicySortService.selectWcsPolicySortById(id));
    }

    /**
     * 新增平均分配参数
     */
    @PreAuthorize("@ss.hasPermi('system:WcsPolicySort:add')")
    @Log(title = "平均分配参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WcsPolicySort wcsPolicySort)
    {
        return toAjax(wcsPolicySortService.insertWcsPolicySort(wcsPolicySort));
    }

    /**
     * 修改平均分配参数
     */
    @PreAuthorize("@ss.hasPermi('system:WcsPolicySort:edit')")
    @Log(title = "平均分配参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WcsPolicySort wcsPolicySort)
    {
        return toAjax(wcsPolicySortService.updateWcsPolicySort(wcsPolicySort));
    }

    /**
     * 删除平均分配参数
     */
    @PreAuthorize("@ss.hasPermi('system:WcsPolicySort:remove')")
    @Log(title = "平均分配参数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wcsPolicySortService.deleteWcsPolicySortByIds(ids));
    }
}
